package Chapter6.complete;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class BookComplete {
	private String title;
	private PublisherComplete publisher;
	private Set<AuthorComplete> authors;
	private int page;
	private int id;
	public Date publicationDate;

	public BookComplete() {
	}

	public BookComplete(String title, int page) {
		this.title = title;
		this.page = page;
	}

	@Column(name = "working_title", length = 200, nullable = false)
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@ManyToOne
	@JoinColumn(name = "publisher_id")
	public PublisherComplete getPublisher() {
		return publisher;
	}

	public void setPublisher(PublisherComplete publisher) {
		this.publisher = publisher;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Transient
	public Date getPublicationDate() {
		return publicationDate;
	}

	public void setPublicationDate(Date publicationDate) {
		this.publicationDate = publicationDate;
	}

	@ManyToMany(cascade = CascadeType.ALL)
	public Set<AuthorComplete> getAuthors() {
		return authors;
	}

	public void setAuthors(Set<AuthorComplete> authors) {
		this.authors = authors;
	}

}
